

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>pyamp.logging.logger &mdash; pyamp v1.2 documentation</title>
    <link rel="stylesheet" href="../../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../../',
        VERSION:     '1.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../../_static/doctools.js"></script>
    <link rel="top" title="pyamp v1.2 documentation" href="../../../index.html" />
    <link rel="up" title="pyamp.logging" href="../logging.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="../../../index.html">pyamp v1.2 documentation</a> &raquo;</li>
          <li><a href="../../index.html" >Module code</a> &raquo;</li>
          <li><a href="../logging.html" accesskey="U">pyamp.logging</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <h1>Source code for pyamp.logging.logger</h1><div class="highlight"><pre>
<span class="c"># Copyright 2012 Brett Ponsler</span>
<span class="c"># This file is part of pyamp.</span>
<span class="c">#</span>
<span class="c"># pyamp is free software: you can redistribute it and/or modify</span>
<span class="c"># it under the terms of the GNU General Public License as published by</span>
<span class="c"># the Free Software Foundation, either version 3 of the License, or</span>
<span class="c"># (at your option) any later version.</span>
<span class="c">#</span>
<span class="c"># pyamp is distributed in the hope that it will be useful,</span>
<span class="c"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span class="c"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<span class="c"># GNU General Public License for more details.</span>
<span class="c">#</span>
<span class="c"># You should have received a copy of the GNU General Public License</span>
<span class="c"># along with pyamp.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>
<span class="sd">&#39;&#39;&#39;The logger module contains the LogLevel, Logger, FileLogger, and LogData</span>
<span class="sd">classes.</span>

<span class="sd">These classes are focused on logging system output to various types of</span>
<span class="sd">output streams (e.g., console, or a file), as well as logging messages at</span>
<span class="sd">various different log levels.</span>

<span class="sd">&#39;&#39;&#39;</span>
<span class="kn">import</span> <span class="nn">logging</span>

<span class="kn">from</span> <span class="nn">pyamp.patterns</span> <span class="kn">import</span> <span class="n">Borg</span>
<span class="kn">from</span> <span class="nn">pyamp.logging.colors</span> <span class="kn">import</span> <span class="n">Colors</span>
<span class="kn">from</span> <span class="nn">pyamp.logging.prefix</span> <span class="kn">import</span> <span class="n">Prefix</span>


<span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span><span class="s">&quot;LogLevel&quot;</span><span class="p">,</span> <span class="s">&quot;Logger&quot;</span><span class="p">,</span> <span class="s">&quot;FileLogger&quot;</span><span class="p">,</span> <span class="s">&quot;SingleLogger&quot;</span><span class="p">,</span> <span class="s">&quot;LogData&quot;</span><span class="p">]</span>


<div class="viewcode-block" id="LogLevel"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.LogLevel">[docs]</a><span class="k">class</span> <span class="nc">LogLevel</span><span class="p">:</span>
    <span class="sd">&#39;&#39;&#39;The LogLevel class contains definitions of all of the various log</span>
<span class="sd">    levels that can be used for logging messages. These levels are designed</span>
<span class="sd">    to make it easier to parse the output of a system to find different types</span>
<span class="sd">    of issues that were encountered at runtime.</span>

<span class="sd">    * **DEBUG** -- The debugging log level. Has a value of 10.</span>
<span class="sd">    * **INFO** -- The information log level. Has a value of 20.</span>
<span class="sd">    * **WARN** -- The warning log level. Has a value of 30.</span>
<span class="sd">    * **WARNING** -- The warning log level. Has a value of 30.</span>
<span class="sd">    * **ERROR** -- The error log level. Has a value of 40.</span>
<span class="sd">    * **CRITICAL** -- The critical log level. Has a value of 50.</span>
<span class="sd">    * **FATAL** -- The fatal log level. Has a value of 50.</span>

<span class="sd">    &#39;&#39;&#39;</span>
    <span class="n">DEBUG</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">DEBUG</span>
    <span class="n">INFO</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">INFO</span>
    <span class="n">WARN</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">WARN</span>
    <span class="n">WARNING</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">WARNING</span>
    <span class="n">ERROR</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">ERROR</span>
    <span class="n">CRITICAL</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">CRITICAL</span>
    <span class="n">FATAL</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">FATAL</span>

</div>
<div class="viewcode-block" id="Logger"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.Logger">[docs]</a><span class="k">class</span> <span class="nc">Logger</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">Logger</span><span class="p">):</span>
    <span class="sd">&#39;&#39;&#39;The Logger class provides the ability to log various types</span>
<span class="sd">    of messages to a specific stream, and formats the messages using given</span>
<span class="sd">    :class:`Prefix` objects.</span>

<span class="sd">    The Logger class will log each :class:`LogLevel` with a colored</span>
<span class="sd">    prefix indicating the name of the log level. Logged messages are only</span>
<span class="sd">    displayed in the event that the :class:`LogLevel` at which they are</span>
<span class="sd">    logged is greater than or equal to the current :class:`LogLevel` of the</span>
<span class="sd">    Logger which is logging the message. Each :class:`LogLevel.DEBUG`</span>
<span class="sd">    message can also have an optional debug level specified, which will allow</span>
<span class="sd">    that message to be displayed so long as the specified debug level is less</span>
<span class="sd">    than or equal to the configured debug level of the Logger object.</span>

<span class="sd">    Each Logger object can be named, and colored, which means that</span>
<span class="sd">    any message logged using that object will be displayed with a prefix</span>
<span class="sd">    indicating the name (and displayed in the specified color) of the object</span>
<span class="sd">    which logged the message.</span>

<span class="sd">    Logger objects can be given a chain of :class:`Prefix` objects.</span>
<span class="sd">    Any message logged using that Logger object will then have a</span>
<span class="sd">    series of prefixes added to the front of the message.</span>

<span class="sd">    Logger objects can also have a handler specified, which specifies</span>
<span class="sd">    the type of stream which will be handled by this Logger. For</span>
<span class="sd">    example, to output to the console a value of :class:`logging.StreamHandler`</span>
<span class="sd">    could be specified, whereas a value of :class:`logging.FileHandler` could</span>
<span class="sd">    be specified to log to a specific file.</span>

<span class="sd">    Example::</span>

<span class="sd">        # Create a Logger with the name &#39;Example1&#39;</span>
<span class="sd">        logger = Logger(&quot;Example1&quot;)</span>
<span class="sd">        logger.info(&quot;Information message&quot;)</span>

<span class="sd">        # Create a Logger with the name &#39;Example2&#39;, a foreground</span>
<span class="sd">        # color of Blue, and logs DEBUG messages that have a debug</span>
<span class="sd">        # level less than or equal to 10.</span>
<span class="sd">        logger = Logger(&quot;Example2&quot;, color=Colors.Foreground.Blue,</span>
<span class="sd">                        logLevel=LogLevel.DEBUG, debugLevel=10)</span>
<span class="sd">        logger.debug(&quot;This message is displayed&quot;, 2)</span>
<span class="sd">        logger.debug(&quot;This message is not displayed&quot;, 11)</span>

<span class="sd">        # Create a Logger with the name &#39;Example3&#39; that only displays</span>
<span class="sd">        # ERROR messages</span>
<span class="sd">        logger = Logger(&quot;Example3&quot;, logLevel=LogLevel.ERROR)</span>
<span class="sd">        logger.warn(&quot;This would not be displayed&quot;)</span>

<span class="sd">    &#39;&#39;&#39;</span>
    <span class="c"># Map log levels to their corresponding string values, and colors</span>
    <span class="n">levelMap</span> <span class="o">=</span> <span class="p">{</span>
        <span class="n">LogLevel</span><span class="o">.</span><span class="n">DEBUG</span><span class="p">:</span> <span class="p">(</span><span class="s">&quot;DEBUG&quot;</span><span class="p">,</span> <span class="n">Colors</span><span class="o">.</span><span class="n">Foreground</span><span class="o">.</span><span class="n">Green</span><span class="p">),</span>
        <span class="n">LogLevel</span><span class="o">.</span><span class="n">INFO</span><span class="p">:</span> <span class="p">(</span><span class="s">&quot;INFO&quot;</span><span class="p">,</span> <span class="n">Colors</span><span class="o">.</span><span class="n">Foreground</span><span class="o">.</span><span class="n">White</span><span class="p">),</span>
        <span class="n">LogLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">:</span> <span class="p">(</span><span class="s">&quot;WARN&quot;</span><span class="p">,</span> <span class="n">Colors</span><span class="o">.</span><span class="n">Foreground</span><span class="o">.</span><span class="n">Orange</span><span class="p">),</span>
        <span class="n">LogLevel</span><span class="o">.</span><span class="n">WARNING</span><span class="p">:</span> <span class="p">(</span><span class="s">&quot;WARN&quot;</span><span class="p">,</span> <span class="n">Colors</span><span class="o">.</span><span class="n">Foreground</span><span class="o">.</span><span class="n">Orange</span><span class="p">),</span>
        <span class="n">LogLevel</span><span class="o">.</span><span class="n">ERROR</span><span class="p">:</span> <span class="p">(</span><span class="s">&quot;ERROR&quot;</span><span class="p">,</span> <span class="n">Colors</span><span class="o">.</span><span class="n">Foreground</span><span class="o">.</span><span class="n">Red</span><span class="p">),</span>
        <span class="n">LogLevel</span><span class="o">.</span><span class="n">CRITICAL</span><span class="p">:</span> <span class="p">(</span><span class="s">&quot;CRITICAL&quot;</span><span class="p">,</span> <span class="n">Colors</span><span class="o">.</span><span class="n">Foreground</span><span class="o">.</span><span class="n">Red</span><span class="p">),</span>
        <span class="n">LogLevel</span><span class="o">.</span><span class="n">FATAL</span><span class="p">:</span> <span class="p">(</span><span class="s">&quot;FATAL&quot;</span><span class="p">,</span> <span class="n">Colors</span><span class="o">.</span><span class="n">Foreground</span><span class="o">.</span><span class="n">Red</span><span class="p">),</span>
        <span class="p">}</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">Colors</span><span class="o">.</span><span class="n">Foreground</span><span class="o">.</span><span class="n">White</span><span class="p">,</span>
                 <span class="n">prefix</span><span class="o">=</span><span class="n">Prefix</span><span class="p">(),</span> <span class="n">logLevel</span><span class="o">=</span><span class="n">LogLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">,</span>
                 <span class="n">debugLevel</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">handler</span><span class="o">=</span><span class="n">logging</span><span class="o">.</span><span class="n">StreamHandler</span><span class="p">()):</span>
        <span class="sd">&#39;&#39;&#39;</span>
<span class="sd">        * name -- The name of the Logger</span>
<span class="sd">        * color -- The color to use for this Logger</span>
<span class="sd">        * prefix -- The :class:`Prefix` chain to use for this Logger</span>
<span class="sd">        * logLevel -- The log level to use for this Logger</span>
<span class="sd">        * debugLevel -- The debug level</span>
<span class="sd">        * handler -- The handler to use for this Logger</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="n">logging</span><span class="o">.</span><span class="n">Logger</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__color</span> <span class="o">=</span> <span class="n">color</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__debugLevel</span> <span class="o">=</span> <span class="n">debugLevel</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logLevel</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">handler</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">setPrefix</span><span class="p">(</span><span class="n">prefix</span><span class="p">)</span>

<div class="viewcode-block" id="Logger.setName"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.Logger.setName">[docs]</a>    <span class="k">def</span> <span class="nf">setName</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Set the name for this logger.</span>

<span class="sd">        * name -- The name</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">name</span>
</div>
<div class="viewcode-block" id="Logger.setPrefix"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.Logger.setPrefix">[docs]</a>    <span class="k">def</span> <span class="nf">setPrefix</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prefix</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Set the prefix for this logger.</span>

<span class="sd">        * prefix -- The prefix</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="c"># Create a default prefix if one was not given</span>
        <span class="n">prefix</span> <span class="o">=</span> <span class="n">Prefix</span><span class="p">()</span> <span class="k">if</span> <span class="n">prefix</span> <span class="ow">is</span> <span class="bp">None</span> <span class="k">else</span> <span class="n">prefix</span>

        <span class="c"># Add the logger&#39;s name prefix onto the end of any prefix given</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__prefix</span> <span class="o">=</span> <span class="n">Prefix</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">__color</span><span class="p">,</span>
                               <span class="n">prefix</span><span class="o">=</span><span class="n">prefix</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Logger.debug"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.Logger.debug">[docs]</a>    <span class="k">def</span> <span class="nf">debug</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Log a debug message.</span>

<span class="sd">        * message -- The message to log</span>
<span class="sd">        * level -- The debug level</span>
<span class="sd">        * args -- The arguments</span>
<span class="sd">        * kwargs -- The keyword arguments</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="c"># Only issue the debug message if the debug level for this</span>
        <span class="c"># message is lower than or equal to the current debug level</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__debugLevel</span> <span class="o">&gt;=</span> <span class="n">level</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">LogLevel</span><span class="o">.</span><span class="n">DEBUG</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Logger.info"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.Logger.info">[docs]</a>    <span class="k">def</span> <span class="nf">info</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Log an info message.</span>

<span class="sd">        * message -- The message to log</span>
<span class="sd">        * args -- The arguments</span>
<span class="sd">        * kwargs -- The keyword arguments</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">LogLevel</span><span class="o">.</span><span class="n">INFO</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Logger.warn"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.Logger.warn">[docs]</a>    <span class="k">def</span> <span class="nf">warn</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Log a warning message.</span>

<span class="sd">        * message -- The message to log</span>
<span class="sd">        * args -- The arguments</span>
<span class="sd">        * kwargs -- The keyword arguments</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">LogLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Logger.warning"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.Logger.warning">[docs]</a>    <span class="k">def</span> <span class="nf">warning</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Log a warning message.</span>

<span class="sd">        * message -- The message to log</span>
<span class="sd">        * args -- The arguments</span>
<span class="sd">        * kwargs -- The keyword arguments</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">LogLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Logger.error"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.Logger.error">[docs]</a>    <span class="k">def</span> <span class="nf">error</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Log an error message.</span>

<span class="sd">        * message -- The message to log</span>
<span class="sd">        * args -- The arguments</span>
<span class="sd">        * kwargs -- The keyword arguments</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">LogLevel</span><span class="o">.</span><span class="n">ERROR</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Logger.fatal"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.Logger.fatal">[docs]</a>    <span class="k">def</span> <span class="nf">fatal</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Log a fatal message.</span>

<span class="sd">        * message -- The message to log</span>
<span class="sd">        * args -- The arguments</span>
<span class="sd">        * kwargs -- The keyword arguments</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">LogLevel</span><span class="o">.</span><span class="n">FATAL</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Logger.critical"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.Logger.critical">[docs]</a>    <span class="k">def</span> <span class="nf">critical</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Log a critical message.</span>

<span class="sd">        * message -- The message to log</span>
<span class="sd">        * args -- The arguments</span>
<span class="sd">        * kwargs -- The keyword arguments</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">LogLevel</span><span class="o">.</span><span class="n">FATAL</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Logger.log"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.Logger.log">[docs]</a>    <span class="k">def</span> <span class="nf">log</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">logLevel</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Log a message at the given log level.</span>

<span class="sd">        * logLevel -- The level at which to log</span>
<span class="sd">        * message -- The message to log</span>
<span class="sd">        * args -- The arguments</span>
<span class="sd">        * kwargs -- The keyword arguments</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="c"># Add a prefix for the given log level onto the logger&#39;s prefix</span>
        <span class="n">prefix</span> <span class="o">=</span> <span class="n">Prefix</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__getLogLevelStr</span><span class="p">(</span><span class="n">logLevel</span><span class="p">),</span>
                        <span class="n">color</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">__getLogLevelColor</span><span class="p">(</span><span class="n">logLevel</span><span class="p">),</span>
                        <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">__prefix</span><span class="p">)</span>

        <span class="n">newMessage</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__getMessage</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

        <span class="c"># Apply the prefix to the message, disabling colors as expected</span>
        <span class="n">useColors</span> <span class="o">=</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__color</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">)</span>
        <span class="n">message</span> <span class="o">=</span> <span class="n">prefix</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span><span class="n">newMessage</span><span class="p">,</span> <span class="n">useColors</span><span class="p">)</span>

        <span class="n">logging</span><span class="o">.</span><span class="n">Logger</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">logLevel</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span>
</div>
    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">__getMessage</span><span class="p">(</span><span class="n">cls</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Return the message including all of the keyword arguments</span>
<span class="sd">        and their corresponding values.</span>

<span class="sd">        * message -- The message to log</span>
<span class="sd">        * kwargs -- The keyword arguments to include in the message</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="c"># The spacing applied before the first keyword in the list</span>
        <span class="n">firstSpacing</span> <span class="o">=</span> <span class="s">&quot;</span><span class="se">\n</span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="s">&#39; &#39;</span> <span class="o">*</span> <span class="mi">9</span><span class="p">)</span>

        <span class="c"># The spacing between each keyword in the list</span>
        <span class="n">spacing</span> <span class="o">=</span> <span class="s">&quot;, &quot;</span>

        <span class="c"># Create strings for each keyword along with its value</span>
        <span class="n">keywords</span> <span class="o">=</span> <span class="nb">map</span><span class="p">(</span><span class="k">lambda</span> <span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">):</span> <span class="s">&quot;</span><span class="si">%s</span><span class="s">=</span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">v</span><span class="p">)),</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">())</span>

        <span class="c"># Create the string with all of the keywords and values</span>
        <span class="n">keywordStr</span> <span class="o">=</span> <span class="s">&#39;&#39;</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">keywords</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
            <span class="n">keywordStr</span> <span class="o">=</span> <span class="s">&quot;</span><span class="si">%s%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">firstSpacing</span><span class="p">,</span> <span class="n">spacing</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">keywords</span><span class="p">))</span>

        <span class="k">return</span> <span class="s">&quot;</span><span class="si">%s%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">keywordStr</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">__getLogLevelStr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">logLevel</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Return the string representation of the given log level.</span>

<span class="sd">        * logLevel -- The log level</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="c"># Find the maximum length of strings</span>
        <span class="n">maxLen</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="nb">map</span><span class="p">(</span><span class="k">lambda</span> <span class="n">i</span><span class="p">:</span> <span class="nb">len</span><span class="p">(</span><span class="n">i</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> <span class="bp">self</span><span class="o">.</span><span class="n">levelMap</span><span class="o">.</span><span class="n">values</span><span class="p">()))</span>
        <span class="n">logStr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">levelMap</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">logLevel</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">logLevel</span><span class="p">))[</span><span class="mi">0</span><span class="p">]</span>

        <span class="c"># Find the spacing to add to the end of the log string</span>
        <span class="c"># to make all of the strings the same length</span>
        <span class="n">spacing</span> <span class="o">=</span> <span class="s">&#39; &#39;</span> <span class="o">*</span> <span class="nb">max</span><span class="p">(</span><span class="n">maxLen</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">logStr</span><span class="p">),</span> <span class="mi">0</span><span class="p">)</span>
        <span class="k">return</span> <span class="s">&quot;</span><span class="si">%s%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">logStr</span><span class="p">,</span> <span class="n">spacing</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">__getLogLevelColor</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">logLevel</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Return the color for the given log level.</span>

<span class="sd">        * logLevel -- The log level</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="n">color</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">levelMap</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">logLevel</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">logLevel</span><span class="p">))[</span><span class="mi">1</span><span class="p">]</span>
        <span class="k">return</span> <span class="n">color</span>

</div>
<div class="viewcode-block" id="FileLogger"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.FileLogger">[docs]</a><span class="k">class</span> <span class="nc">FileLogger</span><span class="p">(</span><span class="n">Logger</span><span class="p">):</span>
    <span class="sd">&#39;&#39;&#39;The FileLogger class provides a wrapper class for a</span>
<span class="sd">    :class:`Logger` object which outputs its messages to a specified</span>
<span class="sd">    file. When creating the FileLogger, it can be specified whether existing</span>
<span class="sd">    files should be overwritten, or appended to, when messages are initially</span>
<span class="sd">    logged to the file.</span>

<span class="sd">    &#39;&#39;&#39;</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="n">Prefix</span><span class="p">(),</span>
                 <span class="n">logLevel</span><span class="o">=</span><span class="n">LogLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;</span>
<span class="sd">        * filename -- The file which will be logged to</span>
<span class="sd">        * overwrite -- True to append to the log file, False to overwrite</span>
<span class="sd">        * name -- The name of the Logger</span>
<span class="sd">        * prefix -- The :class:`Prefix` chain to use for this FileLogger</span>
<span class="sd">        * logLevel -- The log level to use for this FileLogger</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="c"># Determine the writing mode for the file</span>
        <span class="n">mode</span> <span class="o">=</span> <span class="s">&#39;a&#39;</span> <span class="k">if</span> <span class="n">append</span> <span class="k">else</span> <span class="s">&#39;w&#39;</span>

        <span class="c"># Create the file handler with the given filename, and mode</span>
        <span class="n">handler</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">FileHandler</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="n">mode</span><span class="p">)</span>
        <span class="n">Logger</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="n">prefix</span><span class="p">,</span>
                        <span class="n">logLevel</span><span class="o">=</span><span class="n">logLevel</span><span class="p">,</span> <span class="n">handler</span><span class="o">=</span><span class="n">handler</span><span class="p">)</span>

</div>
<div class="viewcode-block" id="SingleLogger"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.SingleLogger">[docs]</a><span class="k">class</span> <span class="nc">SingleLogger</span><span class="p">(</span><span class="n">Borg</span><span class="p">):</span>
    <span class="sd">&#39;&#39;&#39;The SingleLogger class implements the :class:`pyamp.patterns.Borg`</span>
<span class="sd">    design pattern for creating a single system wide :class:`Logger` object.</span>

<span class="sd">    This allows an entire system to access the same :class:`Logger` object so</span>
<span class="sd">    that each component can log messages with the same data (e.g., log level,</span>
<span class="sd">    color, prefix, etc).</span>

<span class="sd">    &#39;&#39;&#39;</span>
    <span class="n">_LoggerName</span> <span class="o">=</span> <span class="s">&quot;_logger&quot;</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Create the SingleLogger object.&#39;&#39;&#39;</span>
        <span class="n">Borg</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">SingleLogger</span><span class="o">.</span><span class="n">_LoggerName</span><span class="p">):</span>
            <span class="nb">setattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">SingleLogger</span><span class="o">.</span><span class="n">_LoggerName</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span>

    <span class="nd">@classmethod</span>
<div class="viewcode-block" id="SingleLogger.getInstance"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.SingleLogger.getInstance">[docs]</a>    <span class="k">def</span> <span class="nf">getInstance</span><span class="p">(</span><span class="n">cls</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Get the instance of the :class:`Logger` object.&#39;&#39;&#39;</span>
        <span class="k">return</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">SingleLogger</span><span class="p">(),</span> <span class="n">SingleLogger</span><span class="o">.</span><span class="n">_LoggerName</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span>
</div>
    <span class="nd">@classmethod</span>
<div class="viewcode-block" id="SingleLogger.createFileLogger"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.SingleLogger.createFileLogger">[docs]</a>    <span class="k">def</span> <span class="nf">createFileLogger</span><span class="p">(</span><span class="n">cls</span><span class="p">,</span> <span class="n">logFile</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">logLevel</span><span class="o">=</span><span class="n">LogLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Create a system-wide :class:`FileLogger` object.</span>

<span class="sd">        * logFile -- The log file to use</span>
<span class="sd">        * append -- True to append to the file, False to overwrite</span>
<span class="sd">        * logLevel -- The log level for the logger</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="n">fileLogger</span> <span class="o">=</span> <span class="n">FileLogger</span><span class="p">(</span><span class="n">logFile</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span>
                                <span class="n">logLevel</span><span class="o">=</span><span class="n">logLevel</span><span class="p">)</span>

        <span class="n">logger</span> <span class="o">=</span> <span class="n">SingleLogger</span><span class="p">()</span>
        <span class="nb">setattr</span><span class="p">(</span><span class="n">logger</span><span class="p">,</span> <span class="n">SingleLogger</span><span class="o">.</span><span class="n">_LoggerName</span><span class="p">,</span> <span class="n">fileLogger</span><span class="p">)</span>
</div>
    <span class="nd">@classmethod</span>
<div class="viewcode-block" id="SingleLogger.createLogger"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.SingleLogger.createLogger">[docs]</a>    <span class="k">def</span> <span class="nf">createLogger</span><span class="p">(</span><span class="n">cls</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">logLevel</span><span class="o">=</span><span class="n">LogLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Create a system-wide :class:`Logger` object.</span>

<span class="sd">        * name -- The name of Logger</span>
<span class="sd">        * logLevel -- The log level for the logger</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="n">theLogger</span> <span class="o">=</span> <span class="n">Logger</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">logLevel</span><span class="o">=</span><span class="n">logLevel</span><span class="p">)</span>

        <span class="n">logger</span> <span class="o">=</span> <span class="n">SingleLogger</span><span class="p">()</span>
        <span class="nb">setattr</span><span class="p">(</span><span class="n">logger</span><span class="p">,</span> <span class="n">SingleLogger</span><span class="o">.</span><span class="n">_LoggerName</span><span class="p">,</span> <span class="n">theLogger</span><span class="p">)</span>
</div>
    <span class="nd">@classmethod</span>
<div class="viewcode-block" id="SingleLogger.debug"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.SingleLogger.debug">[docs]</a>    <span class="k">def</span> <span class="nf">debug</span><span class="p">(</span><span class="n">cls</span><span class="p">,</span> <span class="n">message</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Log the given debug message.</span>

<span class="sd">        * message -- The message to log</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="n">SingleLogger</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">LogLevel</span><span class="o">.</span><span class="n">DEBUG</span><span class="p">,</span> <span class="n">message</span><span class="p">)</span>
</div>
    <span class="nd">@classmethod</span>
<div class="viewcode-block" id="SingleLogger.info"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.SingleLogger.info">[docs]</a>    <span class="k">def</span> <span class="nf">info</span><span class="p">(</span><span class="n">cls</span><span class="p">,</span> <span class="n">message</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Log the given information message.</span>

<span class="sd">        * message -- The message to log</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="n">SingleLogger</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">LogLevel</span><span class="o">.</span><span class="n">INFO</span><span class="p">,</span> <span class="n">message</span><span class="p">)</span>
</div>
    <span class="nd">@classmethod</span>
<div class="viewcode-block" id="SingleLogger.write"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.SingleLogger.write">[docs]</a>    <span class="k">def</span> <span class="nf">write</span><span class="p">(</span><span class="n">cls</span><span class="p">,</span> <span class="n">message</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Write an information message to the logger.</span>

<span class="sd">        * message -- The message to write</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="n">cls</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">LogLevel</span><span class="o">.</span><span class="n">INFO</span><span class="p">,</span> <span class="n">message</span><span class="p">)</span>
</div>
    <span class="nd">@classmethod</span>
<div class="viewcode-block" id="SingleLogger.warn"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.SingleLogger.warn">[docs]</a>    <span class="k">def</span> <span class="nf">warn</span><span class="p">(</span><span class="n">cls</span><span class="p">,</span> <span class="n">message</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Log the given warning message.</span>

<span class="sd">        * message -- The message to log</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="n">SingleLogger</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">LogLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">,</span> <span class="n">message</span><span class="p">)</span>
</div>
    <span class="nd">@classmethod</span>
<div class="viewcode-block" id="SingleLogger.warning"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.SingleLogger.warning">[docs]</a>    <span class="k">def</span> <span class="nf">warning</span><span class="p">(</span><span class="n">cls</span><span class="p">,</span> <span class="n">message</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Log the given warning message.</span>

<span class="sd">        * message -- The message to log</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="n">SingleLogger</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">LogLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">,</span> <span class="n">message</span><span class="p">)</span>
</div>
    <span class="nd">@classmethod</span>
<div class="viewcode-block" id="SingleLogger.error"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.SingleLogger.error">[docs]</a>    <span class="k">def</span> <span class="nf">error</span><span class="p">(</span><span class="n">cls</span><span class="p">,</span> <span class="n">message</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Log the given error message.</span>

<span class="sd">        * message -- The message to log</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="n">SingleLogger</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">LogLevel</span><span class="o">.</span><span class="n">ERROR</span><span class="p">,</span> <span class="n">message</span><span class="p">)</span>
</div>
    <span class="nd">@classmethod</span>
<div class="viewcode-block" id="SingleLogger.fatal"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.SingleLogger.fatal">[docs]</a>    <span class="k">def</span> <span class="nf">fatal</span><span class="p">(</span><span class="n">cls</span><span class="p">,</span> <span class="n">message</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Log the given fatal message.</span>

<span class="sd">        * message -- The message to log</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="n">SingleLogger</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">LogLevel</span><span class="o">.</span><span class="n">FATAL</span><span class="p">,</span> <span class="n">message</span><span class="p">)</span>
</div>
    <span class="nd">@classmethod</span>
<div class="viewcode-block" id="SingleLogger.critical"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.SingleLogger.critical">[docs]</a>    <span class="k">def</span> <span class="nf">critical</span><span class="p">(</span><span class="n">cls</span><span class="p">,</span> <span class="n">message</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Log the given critical message.</span>

<span class="sd">        * message -- The message to log</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="n">SingleLogger</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">LogLevel</span><span class="o">.</span><span class="n">CRITICAL</span><span class="p">,</span> <span class="n">message</span><span class="p">)</span>
</div>
    <span class="nd">@classmethod</span>
<div class="viewcode-block" id="SingleLogger.log"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.SingleLogger.log">[docs]</a>    <span class="k">def</span> <span class="nf">log</span><span class="p">(</span><span class="n">cls</span><span class="p">,</span> <span class="n">logLevel</span><span class="p">,</span> <span class="n">message</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Log the given message at the given log level.</span>

<span class="sd">        * logLevel -- The log level</span>
<span class="sd">        * message -- The message to log</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="n">logger</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">SingleLogger</span><span class="p">(),</span> <span class="n">SingleLogger</span><span class="o">.</span><span class="n">_LoggerName</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">logger</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="n">logger</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">logLevel</span><span class="p">,</span> <span class="n">message</span><span class="p">)</span>

</div></div>
<div class="viewcode-block" id="LogData"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.LogData">[docs]</a><span class="k">class</span> <span class="nc">LogData</span><span class="p">:</span>
    <span class="sd">&#39;&#39;&#39;The LogData class provides the ability to store logging data for an</span>
<span class="sd">    entire system in an object that can be easily handled.</span>

<span class="sd">    The LogData class stores a :class:`LogLevel` and an integer debug level</span>
<span class="sd">    for a system, and provides the ability to create a named :class:`Logger`</span>
<span class="sd">    from the stored values.</span>

<span class="sd">    For example::</span>

<span class="sd">        # Any Logger objects created from this LogData object will have a</span>
<span class="sd">        # LogLevel of DEBUG, and a debug level of 10.</span>
<span class="sd">        logData = LogData(LogLevel.DEBUG, 10)</span>

<span class="sd">        # Create a logger named &#39;ExampleLogger&#39; which will log messages</span>
<span class="sd">        # with a red foreground color.</span>
<span class="sd">        logger = logData.get(&quot;ExampleLogger&quot;, Colors.Foreground.Red)</span>

<span class="sd">        # This message will be displayed</span>
<span class="sd">        logger.debug(&quot;Example message&quot;, 2)</span>

<span class="sd">        # This message will not be displayed</span>
<span class="sd">        logger.debug(&quot;Example message&quot;, 11)</span>


<span class="sd">    LogData objects can be easily passed around which allows the</span>
<span class="sd">    :class::`LogLevel` and debug level values to be easily propagated</span>
<span class="sd">    throughout the system, rather than having individual values for each</span>
<span class="sd">    system component.</span>

<span class="sd">    &#39;&#39;&#39;</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">logLevel</span><span class="o">=</span><span class="n">LogLevel</span><span class="o">.</span><span class="n">INFO</span><span class="p">,</span> <span class="n">debugLevel</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;</span>
<span class="sd">        * logLevel -- The log level</span>
<span class="sd">        * debugLevel -- The debug level</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__logLevel</span> <span class="o">=</span> <span class="n">logLevel</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__debugLevel</span> <span class="o">=</span> <span class="n">debugLevel</span>

<div class="viewcode-block" id="LogData.get"><a class="viewcode-back" href="../../../_generated/pyamp_logging_logger.html#pyamp.logging.logger.LogData.get">[docs]</a>    <span class="k">def</span> <span class="nf">get</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">Colors</span><span class="o">.</span><span class="n">Foreground</span><span class="o">.</span><span class="n">White</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Get a new Logger with the given name.</span>

<span class="sd">        * name -- The name to assign the Logger</span>
<span class="sd">        * color -- The color to use for the Logger</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="k">return</span> <span class="n">Logger</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">logLevel</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">__logLevel</span><span class="p">,</span>
                      <span class="n">debugLevel</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">__debugLevel</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">color</span><span class="p">)</span></div></div>
</pre></div>

          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../../../search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="../../../index.html">pyamp v1.2 documentation</a> &raquo;</li>
          <li><a href="../../index.html" >Module code</a> &raquo;</li>
          <li><a href="../logging.html" >pyamp.logging</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, Brett Ponsler.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.1.
    </div>
  </body>
</html>